package com.monad.firemoth.common.utils;

import cn.hutool.core.util.ObjectUtil;
import lombok.Data;

import java.io.Serializable;

/**
 * @author 单C胞生物
 * @version 1.0.0
 * @date 2024/4/4 23:13
 * @description 统一响应信息
 */
@Data
public class Result implements Serializable {

    private int code;

    private String message;

    private Object data;

    public static Result success() {
        Result result = new Result();
        result.setCode(200);
        result.setMessage("成功!");
        return result;
    }

    public static Result success(String message) {
        Result result = new Result();
        result.setCode(200);
        result.setMessage(message);
        return result;
    }

    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(200);
        result.setMessage("成功!");
        result.setData(data);
        return result;
    }

    public static Result success(String message, Object data) {
        Result result = new Result();
        result.setCode(200);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static Result error() {
        Result result = new Result();
        result.setCode(500);
        result.setMessage("失败!");
        return result;
    }

    public static Result error(String message) {
        Result result = new Result();
        result.setCode(500);
        result.setMessage(message);
        return result;
    }

    public static Result error(Object data) {
        Result result = new Result();
        result.setCode(500);
        result.setMessage("失败!");
        result.setData(data);
        return result;
    }

    public static Result error(String message, Object data) {
        Result result = new Result();
        result.setCode(500);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static Result error(int code, String message) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }

    public static Result response(int code, String message, Object data) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

}
